<?php
class ModelReportAccounting extends Model 
{
	public function ledger($fromdate, $todate, $where = "")
	{
		$sql = "Select * from voucher where voucherdate >= '".$fromdate."' and voucherdate <= '".$todate."'";
		$query = $this->db->query($sql);
		return $query->rows;
	}
	
	public function getstartvoucher($fromdate)
	{
		$sql = "Select (sum(incomeamount)-sum(expenseamount)) as startvoucher from voucher where voucherdate < '".$fromdate."'";
		$query = $this->db->query($sql);
		return $query->row['startvoucher'];
	}
	
	public function businessresult($fromdate, $todate)
	{
		$sql = "Select vouchertype, vouchergroup, (sum(incomeamount)-sum(expenseamount)) as sumtotal from voucher where voucherdate >= '".$fromdate."' and voucherdate <= '".$todate."' group by vouchertype, vouchergroup";
		$query = $this->db->query($sql);
		return $query->rows;
	}
	
}

?>